/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package model;

import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Toshiba Satellite
 */
public class Company extends AbstractTableModel{

    private ArrayList<Entity.Company> arrCom;
    private String[] columnsName = {"Code","Name","Address","Phone","Website","Fax"};
    private Class[] columnsClass = {Integer.class,String.class,String.class,String.class,String.class,String.class};

    public Company(ArrayList<Entity.Company> arrCom)
    {
        this.arrCom = arrCom;
    }

    public int getRowCount()
    {
        return arrCom.toArray().length;
    }

    public int getColumnCount()
    {
        return columnsName.length;
    }

    public Object getValueAt(int rowIndex,int columnIndex)
    {
        switch(columnIndex)
        {
            case 0:
                return arrCom.get(rowIndex).getCompanyID();
            case 1:
                return arrCom.get(rowIndex).getName();
            case 2:
                return arrCom.get(rowIndex).getAddress();
            case 3:
                return arrCom.get(rowIndex).getPhoneNumber();
            case 4:
                return arrCom.get(rowIndex).getWebsite();
            case 5:
                return arrCom.get(rowIndex).getFax();
            default:
                return null;
        }
    }


    @Override
    public String getColumnName(int ColumnIndex)
    {
        return columnsName[ColumnIndex];
    }


    @Override
    public Class getColumnClass(int ColumnTypeIndex)
    {
        return columnsClass[ColumnTypeIndex];
    }

}
